import React, { useEffect, useState } from 'react';
import Recomment from '../recomment';
import results from '../../results';
import { nanoid } from 'nanoid';

const RecommentHandle = ({ type, style }) => {
  const [recomment, setRecomment] = useState([]);
  useEffect(() => {
    setRecomment(results[type].products);
  }, []);

  return (
    <>
      {recomment.map((item) => {
        return (
          <Recomment data={item} type={type} style={style} key={nanoid()} />
        );
      })}
    </>
  );
};

export default RecommentHandle;
